﻿@namespace AntBlazor.Internal
@inherits AntDomComponentBase

<div class="@(PrefixCls)-input">
    <input @ref="Ref"
           @onclick="OnClick"
           @onkeyup='OnKeyUp'
           @oninput='OnInput'
           value="@Value"
           disabled="@Disabled"
           placeholder="@Placeholder"
           readonly="@ReadOnly">
    @if (ShowSuffixIcon)
    {
        <span class="@(PrefixCls)-suffix">

            @if (SuffixIcon != null)
            {
                @SuffixIcon
            }
            else if (ShowTime)
            {
                <span role="img" aria-label="clock-circle" class="anticon anticon-clock-circle">
                    <svg viewBox="64 64 896 896"
                         focusable="false"
                         class=""
                         data-icon="clock-circle"
                         width="1em"
                         height="1em"
                         fill="currentColor"
                         aria-hidden="true">
                        <path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"></path>
                        <path d="M686.7 638.6L544.1 535.5V288c0-4.4-3.6-8-8-8H488c-4.4 0-8 3.6-8 8v275.4c0 2.6 1.2 5 3.3 6.5l165.4 120.6c3.6 2.6 8.6 1.8 11.2-1.7l28.6-39c2.6-3.7 1.8-8.7-1.8-11.2z"></path>
                    </svg>
                </span>
            }
            else
            {
                <span role="img" aria-label="calendar" class="anticon anticon-calendar">
                    <svg viewBox="64 64 896 896" focusable="false" class="" data-icon="calendar" width="1em" height="1em" fill="currentColor" aria-hidden="true">
                        <path d="M880 184H712v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H384v-64c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v64H144c-17.7 0-32 14.3-32 32v664c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V216c0-17.7-14.3-32-32-32zm-40 656H184V460h656v380zM184 392V256h128v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h256v48c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8v-48h128v136H184z"></path>
                    </svg>
                </span>
            }
        </span>
    }
</div>

@code {
    [Parameter]
    public string PrefixCls { get; set; } = "ant-picker";

    [Parameter]
    public string Size { get; set; }

    [Parameter]
    public string Value { get; set; }

    [Parameter]
    public string Placeholder { get; set; }

    [Parameter]
    public bool ReadOnly { get; set; }

    [Parameter]
    public bool Disabled { get; set; }

    [Parameter]
    public bool AutoFocus { get; set; }

    [Parameter]
    public bool ShowSuffixIcon { get; set; } = true;

    [Parameter]
    public bool ShowTime { get; set; } = false;

    [Parameter]
    public RenderFragment SuffixIcon { get; set; }

    [Parameter]
    public EventCallback OnClick { get; set; }

    [Parameter]
    public EventCallback Onfocus { get; set; }

    [Parameter]
    public EventCallback Onfocusout { get; set; }

    [Parameter]
    public EventCallback OnKeyUp { get; set; }

    [Parameter]
    public EventCallback<ChangeEventArgs> OnInput { get; set; }

    public bool IsOnFocused { get; set; } = false;
}